package com.sea.artefactos.service;

import java.util.List;
import javax.persistence.EntityManager;
import com.sea.model.Artefacto;
import com.sea.model.repository.ArtefactosRepository;
import com.sea.util.Utilitario;


public class ArtefactoService{
	
	private ArtefactosRepository artefactoRepository;
	private EntityManager em;
	
	public ArtefactoService()throws RuntimeException{
		System.out.println("Entro al servicio");
		em= Utilitario.getInstance().getEntityManager();
		artefactoRepository = new ArtefactosRepository(em);
	}
		
	
	public void actulizarEstado(Artefacto artefacto){
		System.out.println("Entro al Actualizar");
		
		artefactoRepository.update(artefacto);
		
		}
	
	public List<Artefacto> listarArtefacto(){
		return artefactoRepository.listAll();
	}
	
	public Artefacto obtenerArtefacto(int idart){
		
		return artefactoRepository.findById(idart);
		
		}
}
